//
//  UITableViewCell+XH.m
//  NETWorkingTest
//
//  Created by 郑信鸿 on 16/9/21.
//  Copyright © 2016年 郑信鸿. All rights reserved.
//

#import "UITableViewCell+XH.h"

#define UITableViewCellSeparatorTopTag 9071
#define UITableViewCellSeparatorBottom 9072

@implementation UITableViewCell (XH)


- (UIImageView *)addTopSeparatorLineView{
    
    UIImageView * imageView = [self.contentView viewWithTag:UITableViewCellSeparatorTopTag];
    
    if (imageView == nil)
    {
        imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.contentView.bounds.size.height-0.5, [UIScreen mainScreen].bounds.size.width, 0.5)];
        
        [self.contentView addSubview:imageView];
        
        imageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
        
        //        imageView.image = [UIImage imageWithColor:[UIColor colorFromHexCode:@"d6d6d6"] cornerRadius:0];
         imageView.backgroundColor = RGBColor(105, 105, 105);
        imageView.tag = UITableViewCellSeparatorTopTag;
    }
    
    return imageView;
    
}



- (UIImageView *)addBottomSeparatorLineView
{
    UIImageView * imageView = [self.contentView viewWithTag:UITableViewCellSeparatorBottom];
    
    if (imageView == nil)
    {
        imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.contentView.bounds.size.height-0.5, [UIScreen mainScreen].bounds.size.width, 0.5)];
        
        [self.contentView addSubview:imageView];
        
        imageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
        
        //        imageView.image = [UIImage imageWithColor:[UIColor colorFromHexCode:@"d6d6d6"] cornerRadius:0];
        imageView.backgroundColor = RGBColor(105, 105, 105);
        imageView.tag = UITableViewCellSeparatorBottom;
    }
    
    return imageView;
}


- (void)setSeparatorHide:(BOOL)hide{
    
    [self setTopSeparatorHide:hide];
    [self setBottomSeparatorHide:hide];
    
}

- (void)setTopSeparatorHide:(BOOL)hide{
    
    UIImageView * imageView = [self.contentView viewWithTag:UITableViewCellSeparatorTopTag];
    if (imageView != nil) {
        
        imageView.hidden = hide;
    }
    
}

- (void)setBottomSeparatorHide:(BOOL)hide{
    UIImageView * imageView = [self.contentView viewWithTag:UITableViewCellSeparatorBottom];
    if (imageView != nil) {
        
        imageView.hidden = hide;
    }
}


@end
